home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1879 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: ix.netcom.com!netnews
  2. From: a1s@ix.netcom.com (Andrew Snyder)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Checking for a file => Does it exist (Help)
  5. Date: Wed, 17 Jan 1996 19:04:00 GMT
  6. Organization: Netcom
  7. Message-ID: <4dj6pm$dbg@ixnews6.ix.netcom.com>
  8. References: <4d9k6fINNnja@faatcrl.faa.gov>
  9. NNTP-Posting-Host: ix-har5-17.ix.netcom.com
  10. X-NETCOM-Date: Wed Jan 17  8:06:14 AM PST 1996
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. afrawert@faatcrl.faa.gov (Alan Frawert) wrote:
  14.  
  15.  
  16.  
  17. >            I'm having a problem just checking to see if a file
  18. >exists. Does anyone have a simple piece of code that I can use?
  19.  
  20. >                afrawert@faatcrl.faa.gov
  21.  
  22. This is a job for a system dependent function, since files are system
  23. dependent things.  Some people have suggested the fopen trick, which
  24. doesn't work for two reasons:
  25.  
  26. 1. you can be out of file handles.
  27. 2. the file might exist, but you might not have permissions to read
  28. it.
  29.  
  30. All of the systems I know about have a function called access that can
  31. be used to see if a file exists, is readable, and/or is writable.
  32. Your system must have something like it, although it might not be
  33. called access.
  34.  
  35. If you want to write portable code, write a function wrapper in a
  36. seperate file and put the prototype in a header file somewhere.
  37.  
  38.  
  39. Andrew Snyder
  40. a1s@ix.netcom.com
  41. char disclaimer[] = {'\0'}; /* I'm on cash net */
  42.  
  43.